﻿#include "CPoolTaskRpt.h"
#include "CLogOper.h"
#include "CGlobal.h"

CPoolTaskRpt::CPoolTaskRpt()
{
	setAutoDelete(true);//放到线程池之后，工作完自动析构(任务执行完毕,该对象自动销毁)
	m_pAllDataInfo = new CAllPdfRptDataInfo();
}

CPoolTaskRpt::~CPoolTaskRpt()
{
	if (m_pAllDataInfo != nullptr)
	{
		delete m_pAllDataInfo;
		m_pAllDataInfo = nullptr;
	}
}

void CPoolTaskRpt::setData(CPdfRptRectifyDataInfo &recDataInfo, CPdfRptBase *pRptBase)
{
	m_pRptBase = pRptBase;

	//纠偏数据
	if (m_pAllDataInfo != nullptr)
	{
		m_pAllDataInfo->rectifyDataInfo.m_sOutputPdfFolder = recDataInfo.m_sOutputPdfFolder;

		m_pAllDataInfo->rectifyDataInfo.m_sBeltName = recDataInfo.m_sBeltName;
		m_pAllDataInfo->rectifyDataInfo.m_sDetTime = recDataInfo.m_sDetTime;
		m_pAllDataInfo->rectifyDataInfo.m_sDetStartTime = recDataInfo.m_sDetStartTime;
		m_pAllDataInfo->rectifyDataInfo.m_sDetEndTime = recDataInfo.m_sDetEndTime;
		m_pAllDataInfo->rectifyDataInfo.m_nAlmCount = recDataInfo.m_nAlmCount;
		m_pAllDataInfo->rectifyDataInfo.m_sComment = recDataInfo.m_sComment;

		m_pAllDataInfo->rectifyDataInfo.m_vecFormRecAlmInfo = recDataInfo.m_vecFormRecAlmInfo;
	}
}

void CPoolTaskRpt::run()
{
	if (m_pAllDataInfo == nullptr || m_pRptBase == nullptr)
	{
		return;
	}
	SExecLog sExecLog;
	sExecLog.m_sDevName = A2T("跑偏检测");
	sExecLog.m_nAlarmLevel = enWorkInfo;
	sExecLog.m_sDescriptionl = A2T("开始导出跑偏检测报表");
	sExecLog.m_sFuncName = A2T("报表");
	CLogOper::instance().addMsg(sExecLog);
	//输出
	QString sErrMsg = "";
	m_pRptBase->optRestPdfRptInfo(*m_pAllDataInfo, sErrMsg);
	sExecLog.m_sDevName = A2T("跑偏检测");
	sExecLog.m_nAlarmLevel = enWorkInfo;
	sExecLog.m_sDescriptionl = A2T("导出跑偏检测报表成功");
	sExecLog.m_sFuncName = A2T("报表");
	CLogOper::instance().addMsg(sExecLog);
}
